USE [web-vote]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuario_empresa]') AND parent_object_id = OBJECT_ID(N'[dbo].[usuario]'))
ALTER TABLE [dbo].[usuario] DROP CONSTRAINT [FK_usuario_empresa]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuario_tipo_documento]') AND parent_object_id = OBJECT_ID(N'[dbo].[usuario]'))
ALTER TABLE [dbo].[usuario] DROP CONSTRAINT [FK_usuario_tipo_documento]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuario_UserProfile]') AND parent_object_id = OBJECT_ID(N'[dbo].[usuario]'))
ALTER TABLE [dbo].[usuario] DROP CONSTRAINT [FK_usuario_UserProfile]
GO

USE [web-vote]
GO

/****** Object:  Table [dbo].[usuario]    Script Date: 10/15/2013 02:52:22 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usuario]') AND type in (N'U'))
DROP TABLE [dbo].[usuario]
GO

USE [web-vote]
GO

/****** Object:  Table [dbo].[usuario]    Script Date: 10/15/2013 02:52:22 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[usuario](
	[id_Usuario] [int] NOT NULL,
	[identificacion] [int] NOT NULL,
	[nombres] [varchar](100) NOT NULL,
	[apellidos] [varchar](100) NOT NULL,
	[genero] [char](2) NOT NULL,
	[fecha_nacimiento] [date] NOT NULL,
	[ruta_imagen] [varchar](100) NULL,
	[id_Empresa] [int] NOT NULL,
	[id_tipo_documento] [int] NOT NULL,
 CONSTRAINT [PK_usuario] PRIMARY KEY CLUSTERED 
(
	[id_Usuario] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Numero de cedula del usuario que se esta regsitrando debe ser unico' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'usuario', @level2type=N'COLUMN',@level2name=N'identificacion'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'los posibles valores son M para Masculino y F para Femenino' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'usuario', @level2type=N'COLUMN',@level2name=N'genero'
GO

ALTER TABLE [dbo].[usuario]  WITH CHECK ADD  CONSTRAINT [FK_usuario_empresa] FOREIGN KEY([id_Empresa])
REFERENCES [dbo].[empresa] ([id_empresa])
GO

ALTER TABLE [dbo].[usuario] CHECK CONSTRAINT [FK_usuario_empresa]
GO

ALTER TABLE [dbo].[usuario]  WITH CHECK ADD  CONSTRAINT [FK_usuario_tipo_documento] FOREIGN KEY([id_tipo_documento])
REFERENCES [dbo].[tipo_documento] ([id_tipo_documento])
GO

ALTER TABLE [dbo].[usuario] CHECK CONSTRAINT [FK_usuario_tipo_documento]
GO

ALTER TABLE [dbo].[usuario]  WITH CHECK ADD  CONSTRAINT [FK_usuario_UserProfile] FOREIGN KEY([id_Usuario])
REFERENCES [dbo].[UserProfile] ([UserId])
GO

ALTER TABLE [dbo].[usuario] CHECK CONSTRAINT [FK_usuario_UserProfile]
GO


